package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zx
 * @date 2021/11/17 19:27
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词", tags = "敏感词", description = "敏感词API")
public class AdSensitiveController {

    @Autowired
    AdSensitiveService adSensitiveService;

    /**
     * 敏感词查询列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "敏感词查询")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDTO dto) {

        return adSensitiveService.findByNameAndPage(dto);
    }

    /**
     * 敏感词添加
     * @param adSensitive
     * @return
     */
    @ApiOperation("敏感词添加")
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {

        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 敏感词修改
     * @param adSensitive
     * @return
     */
    @ApiOperation("敏感词修改")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.updateAdSensitive(adSensitive);
    }


    /**
     * 敏感词删除
     * @param id
     * @return
     */
    @ApiOperation("敏感词删除")
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {

        return adSensitiveService.delete(id);
    }

    /**
     * 查询敏感词内容列表
     * @return
     */
    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives(){
        return  adSensitiveService.selectSensitives();
    }
}